package partikelTest1;

import java.awt.Color;
import java.awt.Graphics;
import java.util.*;
import  java.awt.MouseInfo;


public class Particle {

	private int xpos = 0;
	private int ypos = 0;
	private double xDirection = 0;
	private double yDirection = 0;
	private double yDiffDirection = 0;
	private int xSize = 20;
	private int ySize = 20;
	private int frameSizeX = ParticleTest1.WINDOW_SIZE_X - 35; 
	private int frameSizeY = ParticleTest1.WINDOW_SIZE_Y - 60;
	private int mass = 2;
	
	
	public Particle(int xpos, int ypos){
		
		this.xpos = xpos;
		this.ypos = ypos;
		
//		xSpeed = (Math.random()*2)-1;
//		ySpeed = (Math.random()*2)-1;
		xDirection = 2;
		yDirection = 2;
		
	}
	
	public void update(){
		//System.out.println(ypos);
		//		xSpeed += 0.005; 

	
		//if(!(Math.abs(ySpeed) == 400)){
//			if(!isBelowBottom()){
//				yDirection += ParticleTest1.GRAVITY;
//			}			
			if(yDirection >= frameSizeY){
				yDirection = frameSizeY;
			}
			xpos += xDirection;
			ypos += yDirection;

			if(xpos < 0 && xDirection < 0 ){
				xpos += xDirection;
		
				xDirection *= -1;
			}
			if(xpos > frameSizeX){
				xpos -= xDirection; 
				xDirection *= -1;
			}
			if(ypos < 0 && yDirection < 0){
				ypos += yDirection;
				yDirection *= -1;
			}

			if(ypos >= frameSizeY && yDirection > 0){
				//System.out.println(ypos);
				//System.out.println(yDirection);
				yDirection *= -1;
				//			ypos -= ySpeed;
//				if(isBelowBottom()){
//					
//				}


			}
		}
//		if(ySpeed < 1 && ySpeed > -1 && ypos > 380){
//			ySpeed = 0;
//		}
		
	//}
	
	public boolean isBelowBottom(){		
		return ypos >= frameSizeY;
	}
	public int getXPos(){
		return xpos;
	}
	public int getYPos(){
		return ypos;
	}
	public void setXSpeed(int xSpeed){
		this.xDirection = xSpeed;
	}
	public void setYSpeed(int ySpeed){
		this.yDirection = ySpeed;
	}
	public void collision(){
		xDirection*=-1;
		yDirection*=-1;
	}
	
	public void ritaUt(Graphics g){
		g.setColor(Color.black);
//		System.out.println("xpos: "+xpos+"\nYpos: "+ypos);

			
			g.fillOval(xpos, ypos, xSize,ySize);

				
	}
	
}
